package com.ark.cloud.java.persistence.service.impl;


import com.ark.cloud.java.persistence.entity.EndGameDNEvent;
import com.ark.cloud.java.persistence.entity.EntityType;
import com.ark.cloud.java.persistence.mapper.EndGameDNEventMapper;
import com.ark.cloud.java.persistence.mapper.EntityTypeMapper;
import com.ark.cloud.java.persistence.service.EndGameDNEventService;
import com.ark.cloud.java.persistence.utils.UUIDUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EndGameDNEventServiceImpl extends ServiceImpl<EndGameDNEventMapper, EndGameDNEvent> implements EndGameDNEventService {

    @Autowired
    EntityTypeMapper entityTypeDao;

    @Autowired
    private EndGameDNEventMapper endGameDNEventMapper;

    @Override
    public void saveEndGameDNEvent(EndGameDNEvent endGameDNEvent) {
        // entity_type表插入
        EntityType entityType = endGameDNEvent.getMunitionType();

//        随机生成ID
        entityType.setId(UUIDUtil.next());

        entityTypeDao.insert(entityType);

        String typeId = entityType.getId().toString();

        endGameDNEvent.setId(UUIDUtil.next());
        endGameDNEvent.setMunitionId(typeId);
        endGameDNEventMapper.insert(endGameDNEvent);
    }
}
